class SpuCategory < ApplicationRecord
  mount_uploader :avatar, BaseUploader

  validates :name, presence: { message: "名字不能为空" }

  belongs_to :shop
  belongs_to :parent, class_name: 'SpuCategory', foreign_key: 'parent_id', optional: true
  
  has_many :children, class_name: 'SpuCategory', foreign_key: 'parent_id'
  has_many :spus
end
